var templateSrc = "http://www.spider.com.cn";
var spiderpicurl = "http://pic.spider.com.cn/pic/";
//特殊字符正则表达式 
var txt = new RegExp("[,\\',\\'']");
//正整数
var type = "^[0-9]*[1-9][0-9]*$";
var zhengzs = new RegExp(type);
/**保存用户约影基本信息**/
function saveyuey(){
	var signature = $("#signature").val();
	/**感兴趣电影**/
	var filminterest = "";
	$("#filminterest .on").each(function(){
		filminterest += $(this).attr("id") + ",";
	});
	var uheight = $("#uheight").val();
	var uweight = $("#uweight").val();
	/**身材**/
	var mybody = "";
	$("#mybody .on").each(function(){
		mybody += $(this).attr("id") + ",";
	});
	var mycar = $("#mycar").val();
	var fang_sld = $("#fang_sld").val();
	if(signature != ''){
		if (txt.test(signature)){
			$("#signaturenotice").show();
			$("#signaturenotice").text("不能输入“'”特殊字符!");
			$("#signature").focus();
	        return;
		}
		if(signature.length > 60){
			$("#signaturenotice").show();
			$("#signaturenotice").text("不能输入超过60个字!");
			$("#signature").focus();
			return;
		}
	}
	if(uheight != ""){
		if (uheight.match(zhengzs) == null){
			$("#uheightnotice").show();
			$("#uheightnotice").text("只能输入正整数");
			$("#uheight").focus();
	        return;
		}
		if(parseInt(uheight) > 250){
			$("#uheightnotice").show();
			$("#uheightnotice").text("只能输入不大于250的身高!");
			$("#uheight").focus();
	        return;
		}
	}
	if(uweight != ""){
		if (uweight.match(zhengzs) == null){
			$("#uweightnotice").show();
			$("#uweightnotice").text("只能输入正整数");
			$("#uweight").focus();
	        return;
		}
		if(parseInt(uweight) > 250){
			$("#uweightnotice").show();
			$("#uweightnotice").text("只能输入不大于250的体重!");
			$("#uweight").focus();
	        return;
		}
	}
	if(mycar != ""){
		if (txt.test(mycar)){
			$("#mycarnotice").show();
			$("#mycarnotice").text("不能输入“'”特殊字符!");
			$("#mycar").focus();
	        return;
		}
		if(mycar.length > 20){
			$("#mycarnotice").show();
			$("#mycarnotice").text("不能输入超过20个字!");
			$("#mycar").focus();
	        return;
		}
	}
	$("#signaturenotice").hide();
	$("#uheightnotice").hide();
	$("#uheightnotice").hide();
	$("#mycarnotice").hide();
	
	var as = {
		"usertype":"first003",
		"signature":signature,
		"filminterest":filminterest,
		"uheight":uheight,
		"uweight":uweight,
		"mybody":mybody,
		"mycar":mycar,
		"fang_sld":fang_sld
	};
	$.post("newuserjquery.action", as, function(data){
       	var items = data.getElementsByTagName("item");
     	var result = items[0].childNodes[0].nodeValue;
     	if(result == 'error'){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == 'false'){
	   		alert("更新失败");
	   		return ;
     	}else if(result == 'error4'){
	   		$("#signaturenotice").show();
			$("#signaturenotice").text("个性签名包含敏感词，请修改!");
			$("#signature").focus();
	   		return ;
     	}else if(result == 'error5'){
	   		$("#mycarnotice").show();
			$("#mycarnotice").text("车辆包含敏感词，请修改!");
			$("#mycar").focus();
	   		return ;
     	}else{
     		$("#upPop").show();
     	}
   	});
	
}

/**保存用户基本信息**/
function saveinfo(){
	var useralise = $("#alias").val();
	var sex = $('input[name="usex"]:checked').val();
	var year_sld = $("#year_sld").val().replace("年", "");
	var month_sld = $("#month_sld").val().replace("月", "");
	var day_sld = $("#day_sld").val().replace("日", "");
	var uxzvalue = $("#uxzvalue").val();
	var xue_sld = $("#xue_sld").val();
	var zhi_sld = $("#zhi_sld").val();
	var shou_sld = $("#shou_sld").val();
	var _Province = $("#_Province").val();
	var _City = $("#_City").val();
	var _Region = $("#_Region").val();
	if(_Province == '海外'){
		_City = "";
		_Region = "";
	}
	if(_Province == '请选择'){
		_Province = "";
	}
	if(_City == '请选择'){
		_City = "";
	}
	if(_Region == '请选择'){
		_Region = "";
	}
	/**兴趣**/
	var interestall = "";
	$("#interestall .on").each(function(){
		interestall += $(this).attr("id") + ",";
	});
	if(useralise == ''){
		$("#alisenotice").html("请填写昵称");
		$("#alisenotice").show();
		$("#alisewrong").show();
		$("#alias").focus();
		return;
	}
	if (txt.test(useralise)){
        $("#alisenotice").html("不能输入“'”特殊字符");
        $("#alisenotice").show();
		$("#alisewrong").show();
		$("#alias").focus();
        return;
	}
	if(useralise.length > 20){
        $("#alisenotice").show();
		$("#alisewrong").show();
		$("#alias").focus();
		return;
	}
	$("#alisenotice").hide();
	$("#alisewrong").hide();
	if(sex == "" || sex == undefined){
		$("#sexnotice").show();
		$("#sexwrong").show();
		$("#man1").focus();
		return;
	}
	$("#sexnotice").hide();
	$("#sexwrong").hide();
	
	var signature = $("#signature").val();
	/**感兴趣电影**/
	var filminterest = "";
	$("#filminterest .on").each(function(){
		filminterest += $(this).attr("id") + ",";
	});
	var uheight = $("#uheight").val();
	var uweight = $("#uweight").val();
	/**身材**/
	var mybody = "";
	$("#mybody .on").each(function(){
		mybody += $(this).attr("id") + ",";
	});
	var mycar = $("#mycar").val();
	var fang_sld = $("#fang_sld").val();
	if(signature != ''){
		if (txt.test(signature)){
			$("#signaturenotice").show();
			$("#signaturewrong").show();
			$("#signaturenotice").text("不能输入“'”特殊字符");
			$("#signature").focus();
			openMyDiv("signature");
	        return;
		}
		if(signature.length > 60){
			$("#signaturenotice").show();
			$("#signaturewrong").show();
			$("#signaturenotice").text("不能输入超过60个字");
			$("#signature").focus();
			openMyDiv("signature");
			return;
		}
	}
	$("#signaturenotice").hide();
	$("#signaturewrong").hide();
	if(uheight != ""){
		if (uheight.match(zhengzs) == null){
			$("#uheightnotice").show();
			$("#uheightwrong").show();
			$("#uheightnotice").text("只能输入正整数");
			$("#uheight").focus();
			openMyDiv("uheight");
	        return;
		}
		if(parseInt(uheight) > 250){
			$("#uheightnotice").show();
			$("#uheightwrong").show();
			$("#uheightnotice").text("身高不能大于250");
			$("#uheight").focus();
			openMyDiv("uheight");
	        return;
		}
	}
	$("#uheightnotice").hide();
	$("#uheightwrong").hide();
	if(uweight != ""){
		if (uweight.match(zhengzs) == null){
			$("#uweightnotice").show();
			$("#uweightwrong").show();
			$("#uweightnotice").text("只能输入正整数");
			$("#uweight").focus();
			openMyDiv("uweight");
	        return;
		}
		if(parseInt(uweight) > 250){
			$("#uweightnotice").show();
			$("#uweightwrong").show();
			$("#uweightnotice").text("体重不能大于250");
			$("#uweight").focus();
			openMyDiv("uweight");
	        return;
		}
	}
	$("#uweightnotice").hide();
	$("#uweightwrong").hide();
	if(mycar != ""){
		if (txt.test(mycar)){
			$("#mycarnotice").show();
			$("#mycarwrong").show();
			$("#mycarnotice").text("不能输入“'”特殊字符");
			$("#mycar").focus();
			openMyDiv("mycar");
	        return;
		}
		if(mycar.length > 20){
			$("#mycarnotice").show();
			$("#mycarwrong").show();
			$("#mycarnotice").text("不能输入超过20个字");
			$("#mycar").focus();
			openMyDiv("mycar");
	        return;
		}
	}
	$("#mycarnotice").hide();
	$("#mycarwrong").hide();
	var as = {
		"usertype":"first001",
		"useralise":useralise
	};
	$.post("newuserjquery.action", as, function(data){
       	var items = data.getElementsByTagName("item");
     	var result = items[0].childNodes[0].nodeValue;
     	if(result == 'error'){
     		window.location.href = templateSrc + "/userlogin.html";
     	}else if(result == 'fail'){
     		$("#alisenotice").html("此昵称已被其他用户抢注，请修改");
     		$("#alisenotice").show();
			$("#alisewrong").show();
     		return ;
     	}else if(result == 'error5'){
     		$("#alisenotice").html("此昵称包含敏感词，请修改");
     		$("#alisenotice").show();
			$("#alisewrong").show();
     		return ;
     	}else{
     		$("#alisenotice").hide();
			$("#alisewrong").hide();
     		/**验证用户是否绑定手机**/
     		$.post("newuserjquery.action?usertype=three007", null, function(data){
     			var mobiles = data.getElementsByTagName("item");
     			var mobileresult = mobiles[0].childNodes[0].nodeValue;
     			if("false" == mobileresult){
     				$("#mobilenotice").show();
     				$("#mobilewrong").show();
     				$("#mobileverify").focus();
     				return false;
     			}else{
     				$("#mobilenotice").hide();
     				$("#mobilewrong").hide();
     				var as1 = {
						"usertype":"first002",
						"useralise":useralise,
						"sex":sex,
						"year_sld":year_sld,
						"month_sld":month_sld,
						"day_sld":day_sld,
						"uxzvalue":uxzvalue,
						"xue_sld":xue_sld,
						"zhi_sld":zhi_sld,
						"shou_sld":shou_sld,
						"_Province":_Province,
						"_City":_City,
						"_Region":_Region,
						"interestall":interestall,
						"signature":signature,
						"filminterest":filminterest,
						"uheight":uheight,
						"uweight":uweight,
						"mybody":mybody,
						"mycar":mycar,
						"fang_sld":fang_sld
					};
					$.post("newuserjquery.action", as1, function(data){
				       	var items1 = data.getElementsByTagName("item");
				     	var result1 = items1[0].childNodes[0].nodeValue;
				     	if(result1 == 'error'){
		     				window.location.href = templateSrc + "/userlogin.html";
		     			}else if(result1 == 'false'){
				     		alert("更新失败");
				     		return ;
				     	}else if(result1 == 'error4'){
					   		$("#signaturenotice").show();
					   		$("#signaturewrong").show();
							$("#signaturenotice").text("个性签名包含敏感词，请修改");
							$("#signature").focus();
					   		openMyDiv("signature");
							return ;
     					}else if(result1 == 'error5'){
					   		$("#mycarnotice").show();
					   		$("#signaturewrong").show();
							$("#mycarnotice").text("车辆包含敏感词，请修改");
							$("#mycar").focus();
							openMyDiv("mycar");
					   		return ;
				     	}else{
				     		var countalbum = items1[1].childNodes[0].nodeValue;
				     		if(parseInt(countalbum) <= 0){
				     			$("#albumtip").show();
				     		}else{
				     			$("#albumtip").hide();
				     		}
				     		$("#upPop").show();
				     	}
				   	});
     			}
     		});
     	}
   	});
}

function openMyDiv(ele){
	var pse = $("#" + ele).parents(".psElement");
	if(pse.css("display")=="none"){
		pse.css("display","blank");
		pse.prev("h3").find("span").attr("class","ttlclose").text("收起");
		pse.slideDown(300);
	}
}

/**获取多个指定元素class为on的a标签id**/
function getuserinterest(){
	var interestall = "";
	$("#interestall .on").each(function(){
		//alert($(this).attr("id"));
		interestall += $(this).attr("id") + ",";
	});
	alert(interestall);
}

/***用户昵称事件**/
function useralise(type){
	if('a' == type){
		$("#alisenotice").html("昵称不超过20个字符,可由中英文,数字,\"_\" \"-\"组成");
		$("#alisenotice").show();
		$("#alisewrong").hide();
		$("#alisepass").hide();
	}else if('b' == type){
		var useralise = $("#alias").val();
		if(useralise == ''){
			$("#alisenotice").html("请填写昵称!");
			$("#alisenotice").show();
			$("#alisewrong").show();
			return;
		}
		if (txt.test(useralise)){
	        $("#alisenotice").html("不能输入“'”特殊字符!");
	        $("#alisenotice").show();
			$("#alisewrong").show();
	        return;
		}
		if(useralise.length > 20){
	        $("#alisenotice").show();
			$("#alisewrong").show();
			return;
		}
		var as = {
			"usertype":"first001",
			"useralise":useralise
		};
		$.post("newuserjquery.action", as, function(data){
	       	var items = data.getElementsByTagName("item");
	     	var result = items[0].childNodes[0].nodeValue;
	     	if(result == 'error'){
     			window.location.href = templateSrc + "/userlogin.html";
     		}else if(result == 'fail'){
	     		$("#alisenotice").html("此昵称已被其他用户抢注，请修改!");
	     		$("#alisenotice").show();
				$("#alisewrong").show();
	     		return ;
	     	}else if(result == "error5"){
	     		$("#alisenotice").html("昵称包含敏感词，请修改!");
	     		$("#alisenotice").show();
				$("#alisewrong").show();
	     	}else{
	     		$("#alisenotice").hide();
				$("#alisewrong").hide();
				$("#alisepass").show();
	     	}
     	});
	}else if('c' == type){
		var singlength = $("#signature").val();
		if(singlength.length > 60){
			$("#signaturenotice").show();
			$("#signaturenotice").text("不能输入超过60个字!");
			$("#signature").focus();
			return;
		}else{
			$("#signaturenotice").hide();
			$("#signaturenotice").text("");
		}
	}
}

/**年月日中日的选择项**/
function dayselect(){
	var optionarr = "";
	for(var i = 1; i <= 28; i++){
		if(i < 10){
			optionarr += "<option value=0" + i + ">0" + i + "日</option>";
		}else{
			optionarr += "<option value=" + i + ">" + i + "日</option>";
		}
	}
	var month = $("#month_sld").val();
	if("02" == month){
		$("#day_sld").empty();
		$("#day_sld").append(optionarr);
	}else if("04" == month || "06" == month || "09" == month || "11" == month){
		$("#day_sld").empty();
		optionarr += "<option value='29'>29日</option>";
		optionarr += "<option value='30'>30日</option>";
		$("#day_sld").append(optionarr);
	}else{
		$("#day_sld").empty();
		optionarr += "<option value='29'>29日</option>";
		optionarr += "<option value='30'>30日</option>";
		optionarr += "<option value='31'>31日</option>";
		$("#day_sld").append(optionarr);
	}
	getxz();
}

//白羊3.21-4.19、金牛4.20-5.20、双子5.21-6.21、巨蟹6.22-7.22、狮子7.23-8.22、处女8.23-9.22、
//天秤9.23-10.23、天蝎10.24-11.22、射手11.23-12.21、摩羯12.22-1.19、水瓶1.20-2.18、双鱼2.19-3.20
/**js判断星座**/
function getxz(){
	var umonth = $("#month_sld").val();
	var uday = $("#day_sld").val();
	//alert($("#month_sld").val() + " " + $("#day_sld").val());
	var xz = "";
	var uxzvalue = "";
	if((umonth == 3 && uday >= 21) || (umonth == 4 && uday <= 19)){
		xz = "白羊座";
		uxzvalue = "Aries";
	}else if((umonth == 4 && uday >= 20) || (umonth == 5 && uday <= 20)){
		xz = "金牛座";
		uxzvalue = "Taurus";
	}else if((umonth == 5 && uday >= 21) || (umonth == 6 && uday <= 21)){
		xz = "双子座";
		uxzvalue = "Gemini";
	}else if((umonth == 6 && uday >= 22) || (umonth == 7 && uday <= 22)){
		xz = "巨蟹座";
		uxzvalue = "Cancer";
	}else if((umonth == 7 && uday >= 23) || (umonth == 8 && uday <= 22)){
		xz = "狮子座";
		uxzvalue = "Leo";
	}else if((umonth == 8 && uday >= 23) || (umonth == 9 && uday <= 22)){
		xz = "处女座";
		uxzvalue = "Virgo";
	}else if((umonth == 9 && uday >= 23) || (umonth == 10 && uday <= 23)){
		xz = "天秤座";
		uxzvalue = "Libra";
	}else if((umonth == 10 && uday >= 24) || (umonth == 11 && uday <= 22)){
		xz = "天蝎座";
		uxzvalue = "Scorpi";
	}else if((umonth == 11 && uday >= 23) || (umonth == 12 && uday <= 21)){
		xz = "射手座";
		uxzvalue = "Sagitt";
	}else if((umonth == 12 && uday >= 22) || (umonth == 1 && uday <= 19)){
		xz = "摩羯座";
		uxzvalue = "Capricorn";
	}else if((umonth == 1 && uday >= 20) || (umonth == 2 && uday <= 18)){
		xz = "水瓶座";
		uxzvalue = "Aquari";
	}else if((umonth == 2 && uday >= 19) || (umonth == 3 && uday <= 20)){
		xz = "双鱼座";
		uxzvalue = "Pisces";
	}
	$("#uxz").text(xz);
	$("#uxzvalue").val(uxzvalue);
}

/**兴趣轮换切换**/
function selinterest(eid){
	$(eid).toggleClass("on");
}

/**刷新当前页面**/
function freshpage(){
	window.location.href = templateSrc + "/myinfo.html";
}

var jcrop_api, boundx, boundy;
var newpicinfo = "";
var newpicflag = false;
/**上传图片头像**/
function uploadImage(){
	var names = $("#filebox").val().split(".");
	if(names[1] != "gif" && names[1] != "GIF" && names[1] != "jpg" && names[1] != "JPG" && names[1] != "png" && names[1] != "PNG" && names[1] != "jpeg" && names[1] != "JPEG" && names[1] != "png" && names[1] != "PNG"){
        alert("文件格式有误,请重新上传图片！");
        return;
    }
    /**判断用户是否登录**/
	$.post("newuserjquery.action?usertype=first005", null, function(data){
       	var items = data.getElementsByTagName("item");
     	var result = items[0].childNodes[0].nodeValue;
     	if(result == 'error'){
   			window.location.href = templateSrc + "/userlogin.html";
   		}else{
	   		/**判断当前相册是否已有8张照片**/
   			$.post("newuserjquery.action?usertype=first007", null, function(data){
   				var items1 = data.getElementsByTagName("item");
     			var result1 = items1[0].childNodes[0].nodeValue;
     			if(result1 == "false"){
     				alert("您最多可以上传8张图片，目前相册已有8张图片！您可以删除部分图片后再上传！");
     				return false;
     			}else{
     				$.ajaxFileUpload({
						url:'UploadImageServlet?method=head', //需要链接到服务器地址
						secureuri:false,
						fileElementId:'filebox', //文件选择框的id属性
						cache: false,
						type: 'POST',
						dataType: 'text', //服务器返回的格式，可以是json
						success: function (data, status){
							//相当于java中try语句块的用法
							var backreturn = delHtmlTag(data);
							if(backreturn == 'error1'){
								alert("上传图片不能大于4M，请重新上传！");
								return false;
							}else if(backreturn == 'error2'){
								alert("系统繁忙，请稍后再试！");
								return false;
							}else if(backreturn == 'error3'){
								alert("上传失败，可能图片类型或图片大小不符，请检查后重新上传！");
								return false;
							}else{
								newpicinfo = backreturn;
								judage();
								$('#picsuccessPop').show();
							}
						},
						error: function (data, status, e){
							//相当于java中catch语句块的用法
							alert("用户头像上传上传失败!");
						}
					});
     			}
   			});
     	}
	});
}

var judage = function(){
    if(newpicflag = 'false'){
    	var allvalue = newpicinfo.split(",");
		var picpath = spiderpicurl + allvalue[0];
		var ImgObj = new Image(); //判断图片是否存在  
		ImgObj.src = picpath;  
		var loadsuccess = "false";
		/**ie浏览器**/
		if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)){
			if (ImgObj.fileSize > 0){
				loadsuccess = "true";
			}
		}else{
			if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {  
				loadsuccess = "true";
			} 
		}
		if ("true" == loadsuccess) {  
			newpicflag = true;  
			var picpath = spiderpicurl + allvalue[0];
			$("#jc-hidden-image").attr("src",picpath);
			$("#preview").attr("src",picpath);
			
			/**给小图赋值**/
			$("#preview1").attr("src",picpath);
			$("#preview2").attr("src",picpath);
			/**把相册id赋值给隐藏域**/
			$("#albumid").val(allvalue[3]);
			
			//这里防止第二次上传出现混乱，要清理之前的内容
			$(".jcrop-holder").html("");
			$(".jcrop-holder").hide();
			
			$(".jcrop-holder img").attr("src",picpath);
			/**这里的值需要传到后台进行剪切使用**/
			$("#picpath").val(allvalue[0]);
			/**判断是否是预览的图片的标识**/
			$("#preflag").val("preview");
			
			//**截取图片
			$('#jc-hidden-image').ready(function(){
				var api = jQuery.Jcrop('#jc-hidden-image',{
					onChange: updatePreview,
					onSelect: updatePreview,
					setSelect: [ 0, 0, 100, 100 ],
					aspectRatio: 1,
				    onRelease:  clearCoords,
				    keySupport:true
                 });
			});
			$('#picsuccessPop').hide();
		} else {  
			newpicflag = false;
			//500毫秒轮询一次
        	setTimeout(judage, 100);
		}  
    }else{
        //500毫秒轮询一次
        setTimeout(judage, 100);
    }
}

var allpiccontent = "";
var picflag = "false";
var newpicpath = "";
/**上传照片到相册**/
function uploadImagexc(){
	var names = $("#fileboxxc").val().split(".");
	if(names[1] != "gif" && names[1] != "GIF" && names[1] != "jpg" && names[1] != "JPG" && names[1] != "png" && names[1] != "PNG"){
        alert("文件格式有误,请重新上传图片！");
        return;
    }
     /**判断用户是否登录**/
	$.post("newuserjquery.action?usertype=first005", null, function(data){
       	var items = data.getElementsByTagName("item");
     	var result = items[0].childNodes[0].nodeValue;
     	if(result == 'error'){
   			window.location.href = templateSrc + "/userlogin.html";
   		}else{
   			/**判断当前相册是否已有8张照片**/
   			$.post("newuserjquery.action?usertype=first007", null, function(data){
   				var items1 = data.getElementsByTagName("item");
     			var result1 = items1[0].childNodes[0].nodeValue;
     			if(result1 == "false"){
     				alert("您最多可以上传8张图片，目前相册已有8张图片！您可以删除部分图片后再上传！");
     				return false;
     			}else{
     				$.ajaxFileUpload({
						url:'UploadImageServlet?method=album', //需要链接到服务器地址
						secureuri:false,
						fileElementId:'fileboxxc', //文件选择框的id属性
						cache: false,
						type: 'POST',
						dataType: 'text', //服务器返回的格式，可以是json
						success: function (data, status){
							//相当于java中try语句块的用法
							var backreturn = delHtmlTag(data);
							if(backreturn == 'error1'){
								alert("上传图片不能大于4M，请重新上传！");
								return false;
							}else if(backreturn == 'error2'){
								alert("系统繁忙，请稍后再试！");
								return false;
							}else if(backreturn == 'error3'){
								alert("上传失败，可能图片类型或图片大小不符，请检查后重新上传！");
								return false;
							}else{
								var allvalue = delHtmlTag(data).split(",");
								var picpath = spiderpicurl + allvalue[0];
								var aluid = allvalue[3];
								var aluname = allvalue[0].substring(allvalue[0].lastIndexOf("/") + 1);
								if(aluname.length > 10){
									aluname = aluname.substring(0,10) + "...";
								}
								var piccontent = "<li id=\"pic" + aluid + "\">";
								piccontent += "<dl><dt onclick=\"addalbum(this)\"><a href=\"javascript:void(0)\"><img src=\"" + picpath + "\" height=\"118\" alt=\"" + aluname + "\"></a></dt>";
								piccontent += "<dd>" + aluname + "</dd>";
								piccontent += "</dl><p><input type=\"checkbox\" name=\"picsel\" value=\"" + aluid + "\"><a href=\"javascript:void(0)\"><img onclick=\"picdel('signal','" + aluid + "','pic" + aluid + "')\" src=\"images/common/trans.png\" width=\"21\" height=\"21\"></a></p>";
								piccontent += "</li>";
								
								allpiccontent = piccontent;
								newpicpath = picpath;
								judagetwo();
								$('#picsuccessPop').show();
								//alert("上传成功，请等待审核通过后即可显示！");
							}
						},
						error: function (data, status, e){
							//相当于java中catch语句块的用法
							alert("用户头像上传上传失败!");
						}
					});
     			}
   			});
   		}
	});
}

var judagetwo = function(){
    if(picflag = 'false'){
		var ImgObj = new Image(); //判断图片是否存在  
		ImgObj.src = newpicpath;  
		var loadsuccess = "false";
		/**ie浏览器**/
		if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)){
			if (ImgObj.fileSize > 0){
				loadsuccess = "true";
			}
		}else{
			if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {  
				loadsuccess = "true";
			} 
		}
		if ("true" == loadsuccess) {
			picflag = true;
			$('#picsuccessPop').hide();
			$("#myalbumul").prepend(allpiccontent);
		} else {  
			picflag = false;
			//500毫秒轮询一次
        	setTimeout(judagetwo, 100);
		}  
    }else{
        //500毫秒轮询一次
        setTimeout(judagetwo, 100);
    }
}

/**去掉所有html标签**/
function delHtmlTag(str){
	return str.replace(/<[^>]+>/g,"");//去掉所有的html标记
}

// How easy is this??
function updatePreview(c){
	boundx = $("#jc-hidden-image").width();
	boundy = $("#jc-hidden-image").height();
	//得到坐标
	$('#startX').val(c.x);
	$('#startY').val(c.y);
	$('#endX').val(c.x2);
	$('#endY').val(c.y2);
	$('#width').val(c.w);
	$('#height').val(c.h);
	//预览效果
	if (parseInt(c.w) > 0){
		var rx = 130 / c.w;
		var ry = 130 / c.h;
		$('#preview').css({
		width: Math.round(rx * boundx) + 'px',
		height: Math.round(ry * boundy) + 'px',
		marginLeft: '-' + Math.round(rx * c.x) + 'px',
		marginTop: '-' + Math.round(ry * c.y) + 'px'
		});
	}
	if (parseInt(c.w) > 0){
		var rx1 = 80 / c.w;
		var ry1 = 80 / c.h;
		
		$('#preview1').css({
			width: Math.round(rx1 * boundx) + 'px',
			height: Math.round(ry1 * boundy) + 'px',
			marginLeft: '-' + Math.round(rx1 * c.x) + 'px',
			marginTop: '-' + Math.round(ry1 * c.y) + 'px'
		});
	}
	if (parseInt(c.w) > 0){
		var rx2 = 66 / c.w;
		var ry2 = 66 / c.h;
		
		$('#preview2').css({
			width: Math.round(rx2 * boundx) + 'px',
			height: Math.round(ry2 * boundy) + 'px',
			marginLeft: '-' + Math.round(rx2 * c.x) + 'px',
			marginTop: '-' + Math.round(ry2 * c.y) + 'px'
		});
	}
}

function clearCoords(){
	$('#coords input').val('');
}

/**保存截取的头像**/
function mysaveheadpic(){
	/**判断用户是否登录**/
	$.post("newuserjquery.action?usertype=first005", null, function(data){
       	var items = data.getElementsByTagName("item");
     	var result = items[0].childNodes[0].nodeValue;
     	if(result == 'error'){
   			window.location.href = templateSrc + "/userlogin.html";
   			return;
   		}else{
   			var picpath = $('#picpath').val();
			if(picpath == ''){
				alert("请上传头像后保存!");
				return false;
			}
   			var startX = $('#startX').val();
			var startY = $('#startY').val();
			var endX = $('#endX').val();
			var endY = $('#endY').val();
			var width = $('#width').val();
			var height = $('#height').val();
			var albumid = $('#albumid').val();
			var picturesource = $('#picturesource').val();
			var preflag = $('#preflag').val();
			
			var as = {
				"usertype":"first004",
				"picpath":picpath,
				"startX":startX,
				"startY":startY,
				"endX":endX,
				"endY":endY,
				"width":width,
				"height":height,
				"albumid":albumid,
				"picturesource":picturesource,
				"preflag":preflag
			};
			$.post("newuserjquery.action", as, function(data){
		       	var items = data.getElementsByTagName("item");
		     	var result = items[0].childNodes[0].nodeValue;
		     	if(result == 'success'){
		     		var headpic = spiderpicurl + items[1].childNodes[0].nodeValue;
		     		$("#headpic").attr("src",headpic);
		     		$(".phtEdit").hide();
					$(".phtNow").show();
	    			//$("#upPop").show();
	    		}else{
	    			alert("上传失败！");
		     	}
			});
   		}
	});
}

/**从相册或者系统选择头像截取**/
function selpiccut(opicpath,pheight,pwidth,tid,type){
	$("#picturesource").val(type);
	$("#albumid").val(tid);
	$(".photoPop").hide();
	$(".mask").hide();
	$("#preflag").val("");
	var picpath = spiderpicurl + opicpath;
	$("#jc-hidden-image").attr("src",picpath);
	$("#preview").attr("src",picpath);
	
	/**给小图赋值**/
	$("#preview1").attr("src",picpath);
	$("#preview2").attr("src",picpath);
	
	//这里防止第二次上传出现混乱，要清理之前的内容
	$(".jcrop-holder").html("");
	$(".jcrop-holder").hide();
	
	$(".jcrop-holder img").attr("src",picpath);
	/**这里的值需要传到后台进行剪切使用**/
	$("#picpath").val(opicpath);
	//**截取图片
	$('#jc-hidden-image').ready(function(){
		var api = jQuery.Jcrop('#jc-hidden-image',{
			onChange: updatePreview,
			onSelect: updatePreview,
			setSelect: [ 0, 0, 100, 100 ],
			aspectRatio: 1,
		    onRelease:  clearCoords
         });
	});
}

// CheckBox 的全选与取消全选
function checkAll(name){
	var el = document.getElementsByTagName('input');
	var len = el.length;
	for(var i=0; i<len; i++){
		if((el[i].type=="checkbox") && (el[i].name==name)){
			el[i].checked = true;
		}
	}
}
function clearAll(name){
	var el = document.getElementsByTagName('input');
	var len = el.length;
	for(var i=0; i<len; i++){
		if((el[i].type=="checkbox") && (el[i].name==name)){
			el[i].checked = false;
		}
	}
}

/**用户删除图片**/
function picdel(type,picid,itemid){
	var a = confirm("确认执行删除操作？");
	if(a == true){
		/**删除单张图片**/
		if(type == 'signal'){
			var as = {
				"usertype":"first006",
				"picid":picid
			};
			$.post("newuserjquery.action", as, function(data){
		       	var items = data.getElementsByTagName("item");
		     	var result = items[0].childNodes[0].nodeValue;
		     	if(result == 'error'){
	   				window.location.href = templateSrc + "/userlogin.html";
	   			}else if(result == 'false'){
		     		alert("更新失败");
		     		return ;
		     	}else{
		     		$("#" + itemid).remove();
		     		//alert("更新成功");
		     		//$("#upPop").show();
		     	}
		   	});
		/**批量删除**/
		}else{
			var value_arr = new Array();
			$('input[name="picsel"]:checked').each(function(){
	    		value_arr.push($(this).val());//向数组中添加元素
			});
			var valuestr = value_arr.join(',');//将数组元素连接起来以构建一个字符串
			if(valuestr == ''){
				alert("请至少选择一张图片删除！");
				return false;
			}
			var as = {
				"usertype":"first006",
				"picid":valuestr
			};
			$.post("newuserjquery.action", as, function(data){
		       	var items = data.getElementsByTagName("item");
		     	var result = items[0].childNodes[0].nodeValue;
		     	if(result == 'error'){
	   				window.location.href = templateSrc + "/userlogin.html";
	   			}else if(result == 'false'){
		     		alert("更新失败");
		     		return ;
		     	}else{
		     		var temp_id = valuestr.split(",");
		     		for(var t = 0; t < temp_id.length; t++){
		     			if(temp_id[t] != ''){
		     				$("#pic" + temp_id[t]).remove();
		     			}
		     		}
		     		//alert("更新成功");
		     		//$("#upPop").show();
		     	}
		   	});
		}
	}
}

/**删除当前地址**/
function addressdel(addressid){
	$("#deladdid").val(addressid);
	$("#dltaddress").show();
}

function deletereal(){
	var id = $("#deladdid").val();
	var url_remote ="newuserjquery.action?usertype=first008&id=" + id;
   	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
     	var items = data.getElementsByTagName("item");
  		var result = items[0].childNodes[0].nodeValue;
  		if(result == "error"){
			window.location = templateSrc + "/userlogin.html";
   		}else if(result != "success"){
   			$("#systemmsg").show();
			return false;
		}else{
			$("#address" + id).remove();
			$("#dltaddress").hide();
			$('.mask').hide();
		}
   	});
}

/**当前地址设为默认**/
function addresssetdefault(id){
	var url_remote ="newuserjquery.action?usertype=first009&id=" + id;
   	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
     	var items = data.getElementsByTagName("item");
  		var result = items[0].childNodes[0].nodeValue;
  		if(result == "error"){
			window.location = templateSrc + "/userlogin.html";
   		}else if(result != "success"){
   			$("#systemmsg").show();
			return false;
		}else{
			 window.location = "accountaddress.html";
		}
   	});
}


/**编辑当前地址**/
function modifyaddress(id,addressinfo){
	$("#changetext").text("修改收货地址");
	$("#changetext").show();
	$("#commondialog").show();
	var shipname = $("#name" + id).html();
	var td_province = $("#td_province" + id).html();
	var td_city = $("#td_city" + id).html();
	var td_region = $("#td_region" + id).html();
	var td_address = $("#td_address" + id).html();
	var td_zip = $("#td_zip" + id).html();
	var mobile = $("#mobile" + id).html();
	var gdtel = $("#td_gdtel" + id).val();//电话号码
	if(gdtel.indexOf("null") != -1){
		gdtel = "";
	}
	var gdtel_arr = gdtel.split("-");
	var gdtel_pre ="";
	var gdtel_mid = "";
	var gdtel_end = "";
	if(gdtel_arr.length == 1){
		gdtel_pre = gdtel_arr[0];
	}else if(gdtel_arr.length == 2){
		gdtel_pre = gdtel_arr[0];
		gdtel_mid = gdtel_arr[1];
	}else if(gdtel_arr.length == 3){
		gdtel_pre = gdtel_arr[0];
		gdtel_mid = gdtel_arr[1];
		gdtel_end = gdtel_arr[2];
	}
	$("#address_id").val(addressinfo);
	$("#_Province").val(td_province);
	$("#_City").val(td_city);
	$("#_Region").val(td_region);
	$("#_Address").val(td_address);
	
	$("#tel_pre").val(gdtel_pre);
	$("#tel_mid").val(gdtel_mid);
	$("#tel_end").val(gdtel_end);
	$("#name").val(shipname);
	$("#_shipzip").val(td_zip);
	$("#_mobile").val(mobile);
	
	var flag = $("#mainflag" + id).val();
	if(flag == "y"){
		$("#_default").attr("checked", true);
	}else{
		$("#_default").attr("checked", false);
	}
	loadCity(td_province, '_City', '_Region', td_city);
	loadRegion(td_city, '_Region', td_region);
	location.hash="anchor";
}

function KeyChk_Num() {
	var cKey = window.event.keyCode;
	if ((cKey < 48)	|| (cKey > 57) || (cKey == 45)) {
		if(cKey != 58){
			event.keyCode=0;
			event.returnValue=0;
		};
	};
}

/**添加新地址**/
function addaddress(){
	/**统计用户目前地址数大于10则不许添加**/
	var url_remote ="newuserjquery.action?usertype=three004";
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
    	var items = data.getElementsByTagName("item");
   		var result = items[0].childNodes[0].nodeValue;
   		if(result == "error"){
			window.location = templateSrc + "/userlogin.html";
   		}else if(result == "error1"){
   			alert("地址簿最多允许10条记录！");
   			return false;
   		}else if(result = "success"){
   			$("#address_id").val("");
			$("#_Province").val("");
			$("#_City").val("");
			$("#_Region").val("");
			$("#_Address").val("");
			
			$("#tel_pre").val("");
			$("#tel_mid").val("");
			$("#tel_end").val("");
			$("#name").val("");
			$("#_shipzip").val("");
			$("#_mobile").val("");
			$("#_default").attr("checked", false);
			
			$("#changetext").hide();
			$("#commondialog").show();
   		}else{
   			alert("系统繁忙，请稍后再试！");
   			return false;
   		}
   	});
}
//字符
var txt = new RegExp("[,\\',\\'']");
//手机号码
var cellphone = /^1\d{10}$/;
//固定电话
var voctel = /^((\d{3,4})-)(\d{7,8})((-(\d{1,6})){0,1})$/;
/**保存地址信息**/
function saveuseraddress(){
	var name = $("#name").val();
	var province = $("#_Province").val();
	var city = $("#_City").val();
	var region = $("#_Region").val();
	var address = $("#_Address").val();
	var zip = $("#_shipzip").val();
	var mobile = $("#_mobile").val();//手机
	var tel_temp = $("#tel_pre").val()+$("#tel_mid").val();
	var count = $("#count").val();
	var gdtel = "";
	if(name == "") {
		$("#name").focus();
		$("#namespan").html("请输入收货人!");
		return false;
	}else{
		if (txt.test(name)) {
			$("#name").focus();
			$("#weibospan").html("收件人姓名不能输入“'”特殊字符!");
			return;
		}else{
		   $("#namespan").html("*");
		}
	}
	if(null == province || "" == province || "---请选择---" == province){
		$("#_Province").focus();
		$("#provincespan").html("请选择省份!");
 		return false;
	}
	if(null == city || "" == city || "请选择" == city){
		$("#_City").focus();
		$("#provincespan").html("请选择城市!");
	 	return false;
	}
	if(null == region || "" == region || "请选择" == region){
		$("#_Region").focus();
		$("#provincespan").html("请选择市区!");
	 	return false;
	}
	$("#provincespan").html("*");
	if(address == "") {
		$("#_Address").focus();
		$("#addressspan").html("请输入详细地址!");
		return false;
	}else{
		if (txt.test(address)) {
	       $("#_Address").focus();
	       $("#addressspan").html("收件人地址不能输入“'”特殊字符!");
	       return;
	    }else{
			$("#addressspan").html("*");
		}
	}
	if(zip == "") {
		$("#_shipzip").focus();
		$("#zipspan").html("请输入邮编!");
		return false;
	}
	if(isNaN(zip)) {
		$("#_shipzip").focus();
		$("#zipspan").html("请输入正确邮编!");
		return false;
	}
	$("#zipspan").html("*");
	if($("#tel_end").val() != ""){
		gdtel = $("#tel_pre").val() + "-" + $("#tel_mid").val() + "-" + $("#tel_end").val();
	}else if(tel_temp != ""){
		gdtel = $("#tel_pre").val() + "-" + $("#tel_mid").val();
	}
	if(tel_temp == "" && mobile == "") {
		$("#_mobile").focus();
		$("#mobilespan").html("手机或固定电话至少输入一项");
		return false;
	}
	if(gdtel != "" && !voctel.test(gdtel)){
		$("#tel_pre").focus();
		$("#mobilespan").html("固定电话填写有误，格式：021-22339533-852,分机号可选填!");
		return false;
	}
	if( mobile != "" && !cellphone.test(mobile)){
		$("#_mobile").focus();
		$("#mobilespan").html("手机号格式有误，请重新输入!");
		return false;
	}
	$("#mobilespan").html("*");
	var mainflag = $("#_default").attr("checked");

	var address_id = $("#address_id").val();

	var url_remote ="newuserjquery.action?usertype=first010&addressinfo="+address_id+"&name="+name+"&province="+province+"&city="+city+"&region="+region+"&address="+address+"&zip="+zip+"&mobile="+mobile+"&mainflag="+mainflag+"&tel=" + gdtel;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
    	var items = data.getElementsByTagName("item");
   		var result = items[0].childNodes[0].nodeValue;
   		if(result == "error"){
			window.location = templateSrc + "/userlogin.html";
   		}else if(result == "false"){
   			$('.mask').show();
   			$("#systemmsg").show();
   		}else if(result != "success"){
   			$('.mask').show();
   			$("#systemmsgerrcode").html(result);
   			$("#systemmsgtwo").show();
   		}else{
   			var id_new = items[1].childNodes[0].nodeValue;
   			/**操作类型**/
   			var deltype = items[2].childNodes[0].nodeValue;
   			var name_new = items[3].childNodes[0].nodeValue;
   			var province_new = items[4].childNodes[0].nodeValue;
   			var city_new = items[5].childNodes[0].nodeValue;
   			var region_new = items[6].childNodes[0].nodeValue;
   			var address_new = items[7].childNodes[0].nodeValue;
   			var zip_new = items[8].childNodes[0].nodeValue;
   			var mobile_new = items[9].childNodes[0].nodeValue;
   			var mainflag_new = items[10].childNodes[0].nodeValue;
   			var tel_new = items[11].childNodes[0].nodeValue;
   			var addressinfo = items[12].childNodes[0].nodeValue;
   			if(deltype == 'add'){
   				var newcontent = "<li id=\"address" + id_new + "\">";
   					newcontent += "<p>";
   					newcontent += "<span id=\"name" + id_new + "\">" + name_new + "</span>   收 <br>";
   					newcontent += "<span id=\"td_province" + id_new + "\">" + province_new + "</span> <span id=\"td_city" + id_new + "\">" + city_new + "</span>   <span id=\"td_region" + id_new + "\">" + region_new + "</span><br>";
   					newcontent += "<span id=\"td_address" + id_new + "\">" + address_new + "</span> <span id=\"td_zip" + id_new + "\">" + zip_new + "</span><br>";
   					newcontent += "<span id=\"mobile" + id_new + "\">" + mobile_new + "</span>  <input type=\"hidden\" id=\"td_gdtel" + id_new + "\" value=\"" + tel_new + "\"/>";
   					newcontent += "</p>";
   					newcontent += "<p class=\"addtool\">";
   					newcontent += "<a href=\"javascript:void(0)\" onclick=\"modifyaddress('" + id_new + "','"+addressinfo+"')\">编辑</a>";
   					if("n" == mainflag_new){
   						newcontent += "<a onclick=\"addresssetdefault('" + id_new + "')\" id=\"setDft" + id_new + "\" style=\"cursor: pointer\">设为默认</a>";
   					}
   					newcontent += "</p>";
   					newcontent += "<a href=\"javascript:void(0)\" onclick=\"addressdel('" + id_new + "')\" class=\"close clsAddr\">X</a>";
   					newcontent += "<input type=\"hidden\" name=\"mainflag" + id_new + "\" id=\"mainflag" + id_new + "\" value=\"" + mainflag_new + "\"/>";
   					newcontent += "</li>";
   					/**获取li的数量**/
   					var licount = $("#myullist").children("li").length;
   					if(parseInt(licount) > 2){
   						$("#myullist li").eq(0).after(newcontent);
   					}else{
   						$("#myullist").append(newcontent);
   					}
   					$('.mask').show();
   					$("#commondialog").hide();
   					$("#addaddress").show();
   			}else if(deltype == 'modify'){
   				$("#name" + id_new).html(name_new);
				$("#td_province" + id_new).html(province_new);
				$("#td_city" + id_new).html(city_new);
				$("#td_region" + id_new).html(region_new);
				$("#td_address" + id_new).html(address_new);
				$("#td_zip" + id_new).html(zip_new);
				$("#mobile" + id_new).html(mobile_new);
				$("#td_gdtel" + id_new).val(tel_new);
				/**判断默认地址选择框是否选中**/
				if("checked" == mainflag){
	                mainflag = "y";
	            }else{
	                mainflag = "n";
	            }
				$("#mainflag" + id_new).val(mainflag);
				$('.mask').show();
				$("#commondialog").hide();
				$("#mdfaddress").show();
   			}
   		}
   		location.hash = "myullist";
	});
}
var picpath = spiderpicurl;
/**展示商品订单**/
function showorders(ordertype,i){
	$(".olderTab li").removeClass();
	$(".olderTab li").eq(i-1).addClass("on");
	$(".olderWrap .orderWrap").hide();
	$(".olderWrap .orderWrap").eq(i-1).show();
	if(ordertype == 'sp'){
		var url_remote ="newuserjquery.action?usertype=second001";
	   	url_remote = encodeURI(url_remote);
		$.post(url_remote, null, function(data){
	     	var items = data.getElementsByTagName("item");
	  		var result = items[0].childNodes[0].nodeValue;
	  		if(result == "error"){
				window.location = templateSrc + "/userlogin.html";
	   		}else if(result == 'error1'){
	   			$("#spordersdiv").hide();
	   			$("#moresporder").hide();
	   			$("#nosporders").show();
	   		}else if(result != "success"){
	   			$("#systemmsg").show();
				return false;
			}else{
				var datacount = items[1].childNodes[0].nodeValue;
				var ulcontent = "";
				for(var i = 1; i <= parseInt(datacount); i++){
					var data = items[i + 1].childNodes[0].nodeValue;
					var data_temp = data.split(",");
					var status = "";
					var dealto = "";
					var classcontent = "";
					var detailcount = data_temp[5];
					var agentid = data_temp[8];
					var orderurl = data_temp[11];
					var shipstatus = data_temp[12];
					if("n" == data_temp[3] && "n" == data_temp[4]){
						status = "待支付";
						classcontent = "nopay";
						if(agentid == 10){
							var tmpoDate = data_temp[9];
							var qianggoid = data_temp[10];
							dealto = "<a target=\"_blank\" href=\"" + templateSrc + tmpoDate.substring(5,10) + data_temp[6] + "&qianggoid=" + qianggoid + "\" class=\"btn1\">去付款</a>";
						}else{
							dealto = "<a href=\"javascript:void(0)\" onclick=\"orderdetailOn('all','" + data_temp[6] + "')\" class=\"btn1\">去付款</a>";
						}
					}else if("n" == data_temp[3] && "p" == data_temp[4]){
						status = "部分支付";
						dealto = "<a href=\"javascript:void(0)\" onclick=\"orderdetailOn('all','" + data_temp[6] + "')\" class=\"btn1\">去付款</a>";
						classcontent = "nopay";
					}else if("y" == data_temp[3]){
						status = "已完成";
						dealto = "<a target=\"_blank\" href=\"" + templateSrc + "/mycomment.html\" class=\"btn1\">去评论</a>";
						classcontent = "payed";
					}else if("c" == data_temp[3]){
						status = "已取消";
						dealto = "";
						classcontent = "payed";
					}else if("n" == data_temp[3] && "y" == data_temp[4] && "n" == shipstatus){
						status = "全部支付";
						//dealto = "<a target=\"_blank\" href=\"" + templateSrc + "/comment-" + data_temp[7] + ".html\" class=\"btn1\">去评论</a>";
						classcontent = "payed";
					}else if("n" == data_temp[3] && "y" == data_temp[4] && "n" != shipstatus){
						status = "已确认";
						classcontent = "payed";
						dealto = "<a target=\"_blank\" href=\"" + templateSrc + "/mycomment.html\" class=\"btn1\">去评论</a>";
					}
					ulcontent += "<li>";
					ulcontent += "<p class=\"date\">" + data_temp[0] + "</p>";
					ulcontent += "<dl class=\"olderCont\">";
					ulcontent += "<dt><a target=\"_blank\" href=\"" + orderurl + "\"><img src=\"" + data_temp[1] + "\"></a>";
					if(parseInt(detailcount) > 1){
						ulcontent += "<span class=\"amount\"><em>共" + detailcount + "件</em></span>";
					}
					ulcontent += "</dt>";
					ulcontent += "<dd><em>&yen;" + data_temp[2] + "</em><span class=\"" + classcontent + "\">" + status + "</span></dd>";
					ulcontent += "<dd class=\"btn\">" + dealto + "</dd>";
					ulcontent += "</dl>";
					ulcontent += "</li>";
				}
				$("#spordersdiv").show();
	   			$("#moresporder").show();
	   			$("#nosporders").hide();
				$("#sporders li").remove();
				$("#sporders").append(ulcontent);
			}
	   	});
	}
}

function randomidbetter(obj) {
	obj.src = templateSrc + "/verifycode.jsp?" + new Date;
}

/**加载相册图片**/
function initalum(){
	var url_remote ="newuserjquery.action?usertype=three005";
   	url_remote = encodeURI(url_remote);
   	$.post(url_remote, null, function(data){
     	var items = data.getElementsByTagName("item");
  		var result = items[0].childNodes[0].nodeValue;
  		if("error" == result){
  			window.location = templateSrc + "/userlogin.html";
  		}else if("false" == result){
  			$(".alumbcontenttr").remove();
  			$("#alumbcontent").before("<tr class=\"alumbcontenttr\"><td colspan=\"4\">加载失败,请稍后重试</td><tr>");
  		}else{
  			$(".alumbcontenttr").remove();
  			if(result != 0){
  				$("#alumbcontent").before(items[1].childNodes[0].nodeValue);
  			}
  		}
   	});
}

/**验证能否重新设置支付密码**/
function paypasswordreset(){
	var url_remote = "newuserjquery.action?usertype=four002";
	url_remote = encodeURI(url_remote);
	$.ajax({
		async:false,//使用同步的Ajax请求  
		type: "POST",  
		url: url_remote,  
		data: "",  
		success: function(data){
			var items = data.getElementsByTagName("item");
			var result = items[0].childNodes[0].nodeValue;
			if("success" == result){
				document.safeform.submit();
			}else if("error" == result){
				spiderLogin.util.login();
            	return false;
			}else{
				$("#upPop").show();
	    		return false;
			}
		}
	});
}